package com.music.dao;

import com.laoxuai.beans.annotation.Component;
import com.laoxuai.ibatis.support.BaseDao;
import com.music.pojo.Tag;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

@Component
public class TagDao extends BaseDao<Tag, Integer> {

    public List<Tag> selectAll() throws SQLException {
        String sql = "select * from t_tag";
        return runner.query(sql,new BeanListHandler<>(Tag.class));
    }

    public Tag getByName(String name) throws SQLException {
        String sql = "select * from t_tag where name=?";
        return runner.query(sql,new BeanHandler<>(Tag.class),name);
    }
}
